<template>
	<view class="wrap">
    <u-gap height="20" bg-color="#f5f5f5"></u-gap>
		<signature :showCanvas="showCanvas" :signatureImage="signatureImage" @confirmCanvas="confirmCanvas"></signature>
		<u-button v-show="!showCanvas" @click="sign">签名</u-button>
	</view>
</template>

<script>
import signature from '@/components/signature/signature.vue'
import ebus from '@/components/libs/ebus.js'

export default {
	components: {
		signature
	},
	data() {
		return {
      // 打开canvas绘制签名
			showCanvas: true,
			// 是否展示操作菜单
			completionSignPath: '' ,// 签名
      // 签名图片
      signatureImage: ''
		}
	},
  onShow () {
    let url = this.$store.state.signatureImage
    this.signatureImage = url
  },
	methods: {
    // 隐藏canvas签名组件
    confirmCanvas(e) {
      // this.showCanvas = false
      if (e) {
        this.completionSignPath = e
        ebus.$emit('onConfirmSignature', e)
      }
    },
    sign() {
      this.showCanvas = true
    }
  }
}
</script>

<style lang="scss" scoped>
page {
  background: #f5f5f5;
}
.wrap {
  overflow: hidden;
  height: calc(100vh - 44px);
}
</style>
